package org.bb.object;


public class Student {
	// 属性
	private String stuName;
	private String stuNo;
	private int stuScore;
	// 行为

	/**
	 * 打印学生自己的信息
	 */
	public void printMe() {
		System.out.println("姓名：" + this.getStuName() + ",学号：" + this.getStuNo() + ",成绩：" + this.getStuScore());
	}

	public Student() {
		super();
	}

	public Student(String stuName, String stuNo, int stuScore) {
		super();
		this.stuName = stuName;
		this.stuNo = stuNo;
		this.stuScore = stuScore;
	}

	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getStuNo() {
		return stuNo;
	}

	public void setStuNo(String stuNo) {
		this.stuNo = stuNo;
	}

	public int getStuScore() {
		return stuScore;
	}

	public void setStuScore(int stuScore) {
		this.stuScore = stuScore;
	}

	@Override
	public String toString() {
		return "Student [stuName=" + stuName + ", stuNo=" + stuNo + ", stuScore=" + stuScore + "]";
	}

	@Override
	public boolean equals(Object obj) {
		// 地址引用相同，内容肯定相同
		if (this == obj) {
			return true;
		}
		// 其他情况判定
		// 比较对象必须是Student类型
		if (obj instanceof Student) {
			// 向下溯型
			Student stu = (Student) obj;
			// 根据业务逻辑判定内容是否相同
			// 姓名、成绩、学号都相同，内容相等
//			if (this.getStuName().equals(stu.getStuName()) 
//					&& this.getStuNo().equals(stu.getStuNo())
//					&& this.getStuScore() == stu.getStuScore()) {
//				return true;
//			}
			
			return this.getStuName().equals(stu.getStuName()) 
					&& this.getStuNo().equals(stu.getStuNo())
					&& this.getStuScore() == stu.getStuScore();
		}
		return false;
	}

}
